export const getCount = (count) => {
    if (count < 0) {
        return
    }
    if (count < 10000) {
        return count
    }
    if (count < 10000000) {
        return Math.floor(count) + '万'
    }
    return Math.floor(count / 10000000) / 10 + '亦'
}

export const debounce = (fn, delay) => {
    let timer;
    return (...args) => {
        if (timer) {
            clearTimeout(timer)
        }
        timer = setTimeout(() => {
            clearTimeout(timer)
            fn.apply(this, args)
        }, delay)
    }
}

//处理数据，找出第一个没有歌名的排行榜的索引
export const filterIndex = rankList => {
    for (let i = 0, len = rankList.length - 1; i < len; i++) {
        if (rankList[i].length && !rankList[i + 1].tracks.length) {
            return i + 1
        }
    }
}

//处理歌手列表拼接歌手名字

export const getName = list => {
    let str = '';
    list.map((v, i) => {
        str += i === 0 ? v.name : '/' + v.name;
        return v
    })
    return str
}

export const getSizeImage = (url, num = 300) => {
    return `${url}?param=${num}x${num}`
}

//判断一个对象是否为空
export const isEmptyObject = obj => !obj || Object.keys(obj).length === 0;